﻿Public Class FormChangeRoom
    Dim DAReservation As New DSReservationTableAdapters.RESERVATIONTableAdapter

    Dim DARoom As New DSFloorManagemantTableAdapters.ROOMSTableAdapter
    Sub New()

        ' This call is required by the Windows Form Designer.
        InitializeComponent()
        With cboRoom
            .DataSource = DARoom.GetData
            .ValueMember = "ROOM_ID"
            .DisplayMember = "ROOM_NAME"
            .SelectedIndex = -1
        End With
        ' Add any initialization after the InitializeComponent() call.
        With CboRoomChange
            .DataSource = DARoom.GetData
            .ValueMember = "ROOM_ID"
            .DisplayMember = "ROOM_NAME"
            .SelectedIndex = -1
        End With
    End Sub
    Private Sub FormChangeRoom_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub

    Private Sub GroupBox1_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GroupBox1.Enter

    End Sub

    Private Sub BtnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnCancel.Click
        Me.Close()
    End Sub

    Private Sub BtnChange_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnChange.Click
        If ValidateCombobox(cboRoom, "", ErrorProvider1) = False Then Exit Sub
        If ValidateCombobox(CboRoomChange, "", ErrorProvider1) = False Then Exit Sub
        If DARoom.CheckRoomStatus(CboRoomChange.SelectedValue) > 0 Then
            MessageBox.Show("បន្ទប់ កំពុងភ្ញៀថសំរាក់ មិនអាចចុះឈ្មោះ បានទេ!", "Room", MessageBoxButtons.OK, MessageBoxIcon.Error)
            CboRoomChange.SelectAll()
            cboRoom.Focus()

            Exit Sub
        End If
        If LblReservationID.Text <> 0 Then
            If MessageBox.Show("Do you want to change?", "Change", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = Windows.Forms.DialogResult.Yes Then
                If DAReservation.ChangeRoomServation(CboRoomChange.SelectedValue, LblReservationID.Text) = 1 Then
                    DARoom.UpdateRoomStatus(0, cboRoom.SelectedValue)
                    DARoom.UpdateRoomStatus(lblRoomStatus.Text, CboRoomChange.SelectedValue)
                    Me.DialogResult = Windows.Forms.DialogResult.OK
                End If
            End If
        End If
    End Sub
End Class